<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        // Promise.all方法的使用

        // 封装一个get请求的方法
        function getJSON(url) {
            return new Promise(function(resolve, reject) {
                var XHR = new XMLHttpRequest();
                XHR.open('GET', url, true);
                XHR.send();

                XHR.onreadystatechange = function() {
                    if (XHR.readyState == 4) {
                        if (XHR.status == 200) {
                            try {
                                var response = JSON.parse(XHR.responseText);
                                resolve(response);
                            } catch (e) {
                                reject(e);
                            }
                        } else {
                            reject(new Error(XHR.statusText));
                        }
                    }
                }
            })
        }

        var url = 'https://hq.tigerbrokers.com/fundamental/finance_calendar/getType/2017-02-26/2017-06-10';
        var url1 = 'https://hq.tigerbrokers.com/fundamental/finance_calendar/getType/2017-03-26/2017-06-10';

        function renderAll(){
            return Promise.all([getJSON(url),getJSON(url1)])
        }

        renderAll().then(function(value){
            
            console.log(value)
        })

    </script>
</body>
</html>